package com.epoint.juc.unsafecollection;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;

public class Array {

    public static void main(String[] args) {

        // Exception in thread "main" java.util.ConcurrentModificationException
//        List<String> list = new ArrayList<>();
        List<String> list = new CopyOnWriteArrayList<>();

        list.add("jkh");

        list.forEach((e)->{
            list.add("123");
        });

        System.out.println(list);
    }
}
